<template>
  <div>
    <el-form
      ref="form"
      :model="form"
      label-width="80px"
      style="width: 500px; margin: 2px"
    >
      <el-form-item label="设备编号">
        <el-input v-model="form.deviceNumber"></el-input>
      </el-form-item>
      <el-form-item label="灯杆编号">
        <el-input v-model="form.poleNum"></el-input>
      </el-form-item>
      <el-form-item label="所在区域">
        <el-input v-model="form.area"></el-input>
      </el-form-item>
      <el-form-item label="连接状态" style="width: 50%">
        <el-radio-group v-model="form.connectionStatus">
          <el-radio :label="true">在线</el-radio>
          <el-radio :label="false">不在线</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="照明状态" style="width: 50%">
        <el-radio-group v-model="form.illumination">
          <el-radio :label="true">开启</el-radio>
          <el-radio :label="false">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="开启时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.opendate"
            style="width: 419px"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="关闭时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.closedate"
            style="width: 419px"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="add">添加</el-button>
        <el-button @click="list">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { addLightingInfo } from "@/api/iotInfo/LightingInfo";
export default {
  data() {
    return {
      form: {
        deviceNumber: "",
        poleNum: "",
        area: "",
        connectionStatus: true,
        illumination: true,
        opendate: "",
        closedate: "",
      },
    };
  },
  methods: {
    //添加
    add() {
      addLightingInfo(this.form).then((res) => {
        if (res.data) {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.$router.push("/iotInfo/LightingInfo");
        } else {
          this.$message.error("添加失败");
          return;
        }
      });
    },
    //跳转
    list() {
      this.$router.push("/iotInfo/LightingInfo");
    },
  },
  created() {},
};
</script>
<style>
</style>